package server

import (
	"encoding/json"
)

type ProtoMethod uint8

const (
	ProtoMethodConnect ProtoMethod = 1
	ProtoMethodMsg     ProtoMethod = 2
	ProtoMethodClose   ProtoMethod = 3
)

type JsonProto struct {
	Method ProtoMethod `json:"method"`
	ConnId uint8       `json:"connId"`
	Data   []byte      `json:"data,omitempty"`
}

func (tis *JsonProto) Marshal() ([]byte, error) {
	return json.Marshal(tis)
}

func (tis *JsonProto) Unmarshal(data []byte) error {
	return json.Unmarshal(data, tis)
}
